#include "friendlistbox.h"
#include "ui_friendlistbox.h"

FriendListBox::FriendListBox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FriendListBox)
{
    ui->setupUi(this);
    newmessagecount=0;
    ui->label_newcount->hide();
}

FriendListBox::~FriendListBox()
{
    delete ui;
}
void FriendListBox::setAvatar(const QPixmap avatar){
    ui->label_friendlistavatar->setPixmap(avatar);
}

void FriendListBox::setNameContent(const QString name,const QString content){
    //ui->label_friendlistcontent->setText("<p style=font-size:20px;>  "+name+"</p>"
 //                                                                           "<p style=font-size:14px;color:rgb(120,120,120);>  "+content+"</p>");
    setName(name);
    setContent(content);
}

void FriendListBox::setOC(QString oc)
{
    this->oc=oc;
}

QString FriendListBox::getOC()
{
    return this->oc;
}

QString FriendListBox::getName()
{
    return this->name;
}

void FriendListBox::setName(QString name)
{
    this->name=name;
    ui->label_friendname->setText(name);
}

void FriendListBox::setContent(QString content)
{
    ui->label_lastest->setText(content);
}

void FriendListBox::resetCount()
{
    newmessagecount=0;
    ui->label_newcount->hide();
}

int FriendListBox::getCount()
{
    return newmessagecount;
}

void FriendListBox::raiseCount()
{
    if(ui->label_newcount->isHidden())ui->label_newcount->show();
    newmessagecount++;
    if(newmessagecount>=99)
    {
        ui->label_newcount->setText("99+");
        return;
    }
    ui->label_newcount->setNum(newmessagecount);
}
